From 8d2b933b01889bde3e89892c86decefcfb2cd8e0 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Bartosz=20Dziewo=C5=84ski?= Date: Sat, 10 Jan 2015 03:55:38 +0100 Subject: [PATCH] installer: Don't generate $wgDefaultSkin='' when no skins are present during installation The bug only affects people installing from Git, not tarball releases. * Make sure getDefaultSkin() never returns null and just uses 'vector' when no skins are available (so the user just has to install it). * Produce a hidden input field to pass the generated value to the next installer page. Change-Id: I025f1aeb182a818de59a42df01591e01fc9e6236 --- includes/installer/Installer.php | 7 ++++--- includes/installer/WebInstallerPage.php | 11 +++++++---- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/includes/installer/Installer.php b/includes/installer/Installer.php index 4159c1dc34..f2e417dda7 100644 --- a/includes/installer/Installer.php +++ b/includes/installer/Installer.php @@ -1469,15 +1469,16 @@ abstract class Installer { } /** - * Returns a default value to be used for $wgDefaultSkin: the preferred skin, if available among - * the installed skins, or any other one otherwise. + * Returns a default value to be used for $wgDefaultSkin: normally the one set in DefaultSettings, + * but will fall back to another if the default skin is missing and some other one is present + * instead. * * @param string[] $skinNames Names of installed skins. * @return string */ public function getDefaultSkin( array $skinNames ) { $defaultSkin = $GLOBALS['wgDefaultSkin']; - if ( in_array( $defaultSkin, $skinNames ) ) { + if ( !$skinNames || in_array( $defaultSkin, $skinNames ) ) { return $defaultSkin; } else { return $skinNames[0]; diff --git a/includes/installer/WebInstallerPage.php b/includes/installer/WebInstallerPage.php index 9ecb24b7b7..038c2bea43 100644 --- a/includes/installer/WebInstallerPage.php +++ b/includes/installer/WebInstallerPage.php @@ -1033,14 +1033,15 @@ class WebInstallerOptions extends WebInstallerPage { $skins = $this->parent->findExtensions( 'skins' ); $skinHtml = $this->getFieldSetStart( 'config-skins' ); - if ( $skins ) { - $skinNames = array_map( 'strtolower', $skins ); + $skinNames = array_map( 'strtolower', $skins ); + $chosenSkinName = $this->getVar( 'wgDefaultSkin', $this->parent->getDefaultSkin( $skinNames ) ); + if ( $skins ) { $radioButtons = $this->parent->getRadioElements( array( 'var' => 'wgDefaultSkin', 'itemLabels' => array_fill_keys( $skinNames, 'config-skins-use-as-default' ), 'values' => $skinNames, - 'value' => $this->getVar( 'wgDefaultSkin', $this->parent->getDefaultSkin( $skinNames ) ), + 'value' => $chosenSkinName, ) ); foreach ( $skins as $skin ) { @@ -1055,7 +1056,9 @@ class WebInstallerOptions extends WebInstallerPage { ''; } } else { - $skinHtml .= $this->parent->getWarningBox( wfMessage( 'config-skins-missing' )->plain() ); + $skinHtml .= + $this->parent->getWarningBox( wfMessage( 'config-skins-missing' )->plain() ) . + Html::hidden( 'config_wgDefaultSkin', $chosenSkinName ); } $skinHtml .= $this->parent->getHelpBox( 'config-skins-help' ) . -- 2.20.1